<template>
  <div>
    <!--    <post-list :list="searchPostList"></post-list>-->
    <post-list :list="searchResult"></post-list>
  </div>
</template>

<script>
import {ref, reactive} from "vue";
import {get, put, post, tip, del} from "@/common";
import {message} from 'ant-design-vue';
import PostList from "@/components/score/PostList.vue";
import {useRouter, useRoute} from "vue-router";

export default {
  beforeRouteUpdate(to, from, next) {
    this.searchQuery.s=to.query.searchStr;
    this.getSearch(this.searchQuery);
    next();
  },
  components: {PostList},
  setup() {
    const searchQuery = reactive({
      s: useRoute().query.searchStr,
    })

    const searchResult=ref({});

    const getSearch=(searchQuery)=>{
      post("/post/selectarticlebyword",searchQuery).then((res)=>{
        searchResult.value=res.data;
        console.log(searchResult)
      })
    }
    getSearch(searchQuery)

    return{
      searchQuery,
      getSearch,
      searchResult
    }
  }

}


</script>

<style scoped>

</style>